<?php
	use_helper('MyText');
	use_stylesheet('addressbook.css');
?>
<h1>Adressbuch</h1>

<form action="<?php echo url_for('addressbook'); ?>" method="post">
<?php echo $form->renderHiddenFields(false) ?>
  <fieldset>
    <legend>Suche</legend>
    <?php echo $form; ?>
    <input type="submit" value="Suchen" />
  </fieldset>
</form>

<?php if(isset($keyword)):?>
<h2>Ergebnisse zu "<?php echo $keyword;?>"</h2>
<p><?php echo _n($results, 'Kein Ergebnis', '%s Ergebnis', '%s Ergebnisse')?> gefunden</p>

<?php if(count($results) > 0):?>
<ul class="addressbook_results">
  <?php foreach ($results as $result): ?>
  <?php $type = get_class($result->getRawValue());?>
  <li class="<?php echo strtolower($type);?>">  
    <?php if($type == 'Member'): ?>
      <p><strong><?php echo $result->getFullName();?></strong> <?php if($result->getEmail()):?>(<?php echo $result->getEmail();?>)<?php endif;?></p>
      <?php if($result->PhoneContacts):?>
      <p>
      <?php foreach($result->PhoneContacts as $i => $c):?>
        <?php include_partial('global/phone_contact', array('phonecontact' => $c->getRawValue())); ?>
      <?php endforeach; ?>
      </p>
      <?php endif;?>
      <?php if($result->Addresses):?>
      <p>
      <?php foreach($result->Addresses as $address):?>
        <p><?php include_partial('global/address', array('address' => $address))?></p>
      <?php endforeach;?>
      </p>
      <?php endif;?>
    <?php elseif($type == 'Address'):?>
      <p><?php include_partial('global/address', array('address' => $result))?></p>
    <?php elseif($type == 'PhoneContact'):?>
    Fon
    <?php endif;?>
  </li>
  <?php endforeach;?>
</ul>
<?php endif; ?>
<!--

<div class="split_layout_vertical">
  <?php if(count($members) > 0):?>
  <div class="split_layout_inline medium">
    <?php foreach($members as $member):?>
    <p><?php echo $member->getFirstName(); ?></p>
    <?php endforeach;?>
  </div>
  <?php endif; ?>
  <?php if(count($addresses) > 0):?>
  <div class="split_layout_inline medium">
    <?php foreach($addresses as $address): ?>
    <p><?php echo $address->getStreet(); ?></p>
    <?php endforeach;?>
  </div>
  <?php endif; ?>
  <?php if(count($phonecontacts) > 0):?>
  <div class="split_layout_inline medium">
    <?php foreach($phonecontacts as $phonecontact): ?>
    <p><?php echo $phonecontact->getDialingCode(); ?></p>
    <?php endforeach; ?>
  </div>
  <?php endif;?>
</div>

--><?php endif;?>